Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: alert enriching is always disposable (no matter query params) #2293

Merged
merged 4 commits into from
Oct 24, 2024

Conversation

imorph
Copy link
Contributor

@imorph imorph commented Oct 24, 2024

📑 Description

/close #2292

In _enrich_alert function, you have the following parameter:

dispose_on_new_alert: Optional[bool] = Query(False, description="Dispose on new alert")

Here, you're using Query, which is designed to be used in FastAPI endpoint functions to declare query parameters. When you use Query, FastAPI expects to parse this parameter from the incoming HTTP request.

However, _enrich_alert is not an endpoint function; it's a helper function that's being called directly from another function (enrich_alert). Seems like FastAPI's dependency injection system isn't in play for _enrich_alert, and dispose_on_new_alert is not being set from the HTTP request query parameters. Instead, it's getting assigned the Query object itself as the default value. Since dispose_on_new_alert is set to the Query object, it becomes truthy in a boolean context. Therefore, when execution reach if dispose_on_new_alert condition in _enrich_alert it evaluates as True.

In logs it looks like this:

"Request started: POST /alerts/enrich",  # NO ?dispose_on_new_alert=true here
"Enriching alert", 
"Enriching disposable enrichments",  # yet notes are treated as disposable

✅ Checks

  • My pull request adheres to the code style of this project
  • My code requires changes to the documentation
  • I have updated the documentation as required
  • All the tests have passed

@dosubot dosubot bot added the size:S This PR changes 10-29 lines, ignoring generated files. label Oct 24, 2024
Copy link

vercel bot commented Oct 24, 2024

@imorph is attempting to deploy a commit to the KeepHQ Team on Vercel.

A member of the Team first needs to authorize it.

@dosubot dosubot bot added the Bug Something isn't working label Oct 24, 2024
@shahargl
Copy link
Member

@imorph great catch! waiting for tests and merging!

talboren
talboren previously approved these changes Oct 24, 2024
Copy link
Member

@talboren talboren left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM, thank you! Great catch 🫶

@dosubot dosubot bot added the lgtm This PR has been approved by a maintainer label Oct 24, 2024
@dosubot dosubot bot added size:M This PR changes 30-99 lines, ignoring generated files. and removed size:S This PR changes 10-29 lines, ignoring generated files. labels Oct 24, 2024
Copy link

vercel bot commented Oct 24, 2024

The latest updates on your projects. Learn more about Vercel for Git ↗︎

1 Skipped Deployment
Name Status Preview Comments Updated (UTC)
keep ⬜️ Ignored (Inspect) Visit Preview Oct 24, 2024 4:41pm

@shahargl shahargl self-requested a review October 24, 2024 16:36
@talboren talboren force-pushed the fix_default_disposability_for_notes branch from e27c93a to ef8fdf4 Compare October 24, 2024 16:38
shahargl
shahargl previously approved these changes Oct 24, 2024
Copy link
Member

@shahargl shahargl left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

lgtm

@talboren talboren enabled auto-merge (squash) October 24, 2024 16:39
@shahargl shahargl self-requested a review October 24, 2024 16:40
Copy link
Member

@shahargl shahargl left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

lgtm

@talboren talboren merged commit 0574067 into keephq:main Oct 24, 2024
9 checks passed
Copy link
Contributor

💪 Well done @imorph! Two PRs merged already! 🎉🥳

With your second PR, you're on a roll, and your contributions are already making a difference. 🌟
Looking forward to seeing even more contributions from you. See you in Slack https://slack.keephq.dev 🚀

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Bug Something isn't working lgtm This PR has been approved by a maintainer size:M This PR changes 30-99 lines, ignoring generated files.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[🐛 Bug]: Manual notes and dismissions are disappearing when new event arrives for an alert
3 participants